/*
 * jPushUser.js
 * name:xiaojia 小嘉
 * email:iatt@qq.com
 * qq:273142650
 * time:2012.4.3 14:38
*/

var jPushUser = {

	data: {

		userinfo: null

	},

	refresh: function () {

		this.data.userinfo = null;

	},

	userState: function () {

		return this.userinfo().find('add:[key=state]').attr('value');

	},

	userinfo: function () {

		if (this.data.userinfo != null) {

			return this.data.userinfo;

		} else {

			var _userinfo;

			$.ajax({

				type: 'GET',

				url: jPush.data.Config.userinfo,

				cache: false,

				async: false,

				dataType: 'xml',

				success: function (xmlHttp) {

					_userinfo = $(xmlHttp).find('UserInfo');

				}

			});

			this.data.userinfo = _userinfo;

			return this.data.userinfo;

		}

	},

	login: function (data, callback) {

		$.ajax({

			type: 'POST',

			url: jPush.data.Config.login,

			data: data,

			cache: false,

			dataType: 'xml',

			success: function (xmlHttp) {
				
				callback(xmlHttp);

			}

		});

	}

}